package com.run.hbase.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;

public class Constant {
	static Properties prop = new Properties();
	
	public static boolean EHCACHE_ENABLE = Boolean.parseBoolean(prop.getProperty("ehcache_enable"));
	
	public static ConcurrentHashMap<String,String> personinfoMap = new ConcurrentHashMap<String, String>();
	
	public static ConcurrentHashMap<String,String> qqgroupMap = new ConcurrentHashMap<String, String>();
	
	public static ConcurrentHashMap<String,String> qqgroupmemberMap = new ConcurrentHashMap<String, String>();
	
	public static ConcurrentHashMap<String,String> qqfriendMap = new ConcurrentHashMap<String, String>();
	
	public static String MASTER = "";

	public static String ZOOKEEPER = "";

	public static String HDFS = "";

	public static List<String> BLACKLIST = null;

	public static String DBSEARCH_CONFIG = "dbsearch-config.xml";

	public static final String LIKE_SEPARATIVE = "\u0002";

	/** HTable pool的最大连接数 */
	public static int HTABLE_MAXCONNECT = Integer.parseInt(prop.getProperty("htable_maxconnect"));
	
	/** Hbase分片Scan的数量 */
	public static int GROUP_SIZE = Integer.parseInt(prop.getProperty("group_size"));
	/** 全网搜 Hbase分片Scan的数量 */
	public static int SCAN_SIZE =  Integer.parseInt(prop.getProperty("scan_size"));
	/** 数据源为0（固网） */
	public final static String DATASOUCE_NET = "0";
	
	/** 数据源为1,2,3（无线） */
	public final static String DATASOUCE_3G = "123";
	
	/** 数据源为0（固网） */
	public final static String DATASOUCE_SCODE = "516";

	/** 数据源为5,16（网吧、宾馆） */
	public final static String SPLIT_CONTENT = "    ";

	/** DDB接口传参MAP中实体key（对应的value为Entity实体类型） */
	public final static String ENTITY = "entity";
	
	/** DDB接口传参MAP中的实体名字key（对应的value为String类型大小写敏感） */
	public final static String ENTITY_NAME = "EntityName";
	
	/** DDB接口传参MAP中操作类型key（对应的value为String类型：i增,d删,u改,s为查询列表,sn为查询信息总数） */
	public final static String OPERA = "opera";
	
	/** DDB接口传参MAP中分页信息的当前页 */
	public final static String CUR_PAGE = "curPage";
	
	/** DDB接口传参MAP中分页信息的每页信息条数 */
	public final static String PAGE_SIZE = "pageSize";
	
	/** DDB接口传参MAP中分页信息的信息总条数 */
	public final static String TOTAL = "total";
	
	/** SQL查询条件关系为and */
	public final static String ANDENABLE = " and ";
	
	/** SQL查询条件关系为or */
	public final static String ORENABLE = " or ";
	
	/** 数据挖掘级别 */
	public static int DIGLIMIT = 200;

	/** TRS的ProtocolType和NAME */
	public static HashMap<Integer, String> protocolMap = new HashMap<Integer, String>();

	/** TRS的ProtocolType和DESC */
	public static Map<Integer, String> protocolDescMap = new HashMap<Integer, String>();

	/** 判断聊天记录中是否应该含有数据源信息 */
	public static boolean CHAT_WITH_DS_ENABLE = false;

	public final static String PROTOCOLNAME_EX = "DATA";
	
	/** 伴随关系查询使用的分隔符 */
	public final static String SEPARATIVE_SIGN = ",";
	/**
	 * 1代表终端上下线查询 0代表查询虚拟身份轨迹
	 */
	public final static String ACTIVITY_TYPE = "1";
	
	/** HBase分隔符 */
	public final static String ROWKEY_SEPARATIVE = "\u0001";

	/** HBase分隔符 */
	public final static String QUALIFIER_SEPARATIVE = "~";

	/** AND操作符 */
	public final static String AND_OPERATOR = "and";

	/** SearchId标识符 */
	public final static String CACHE_SEARCHID = "searchId";

	/** QQ账号默认小协议类型 */
	public final static String QQ_CHAT = "~~1015";
	
	/** 行为日志表 */
	public static String ACTIONLOG = prop.getProperty("actionlog");
	
	/** IP索引表 */
	public static String ACTIONLOG_IDX_IP = prop.getProperty("actionlog_idx_ip");
	
	/** 对象关系表 */
	public static String OBJECT_RELATION = prop.getProperty("object_relation");
	
	/** 对象基本信息表 */
	public static String OBJECT_INFO = prop.getProperty("object_info");
	
	/** 配置scan的caching */
	public static int CACHE_SIZE = Integer.parseInt(prop.getProperty("cache_size"));
	
	/** 升序排序标识:0 */
	public static String ORDER_BY_ASC = "0";
	
	/** 降序排序标识:1 */
	public static String ORDER_BY_DESC = "1";
	

	public static int GETRESULTCOUNT = Integer.parseInt(prop.getProperty("getresultcount"));
	

	public enum LEVEL {
		LEVEL_1, LEVEL_2, LEVEL_3, LEVEL_4
	}

	public enum RESULT_COUNT {
		RESULT_5, RESULT_10, RESULT_20, RESULT_50
	}

	public static int translate_LEVEL(Constant.LEVEL level) {
		switch (level) {
		case LEVEL_1:
			return 1;
		case LEVEL_2:
			return 2;
		case LEVEL_3:
			return 3;
		case LEVEL_4:
			return 4;
		default:
			return 1;
		}
	}

	public static int translate_NUM(Constant.RESULT_COUNT count) {
		switch (count) {
		case RESULT_5:
			return 5;
		case RESULT_10:
			return 10;
		case RESULT_20:
			return 20;
		case RESULT_50:
			return 50;
		default:
			return 10;
		}
	}
}
